//package com.funny.stock.trade.service;
//
//import com.funny.stock.base.service.BaseCrudServiceV2;
//import com.funny.stock.base.util.PageUtil;
//import com.funny.stock.base.util.PropertiesCopyUtil;
//import com.funny.stock.trade.dao.pojo.ComposeAssetsActionDO;
//import com.funny.stock.trade.dao.pojo.ComposeAssetsDO;
//import com.funny.stock.trade.dao.repo.ComposeAssetsActionRepo;
//import com.funny.stock.trade.vo.ComposeAssetsActionVO;
//import com.funny.stock.trade.vo.ComposeAssetsVO;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.data.jpa.domain.Specification;
//import org.springframework.data.jpa.repository.JpaRepository;
//import org.springframework.stereotype.Service;
//
//import javax.persistence.criteria.CriteriaBuilder;
//import javax.persistence.criteria.CriteriaQuery;
//import javax.persistence.criteria.Predicate;
//import javax.persistence.criteria.Root;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @Description
// * @Author  pengl
// * @Date 2020-05-17
// */
//
//@Service
//public class ComposeAssetsActionService extends BaseCrudServiceV2<ComposeAssetsActionVO,ComposeAssetsActionDO,Long> {
//
//	@Autowired
//	ComposeAssetsActionRepo repository;
//
//	@Autowired
//	ComposeAssetsActionHelper assetsActionHelper;
//
//	protected JpaRepository<ComposeAssetsActionDO, Long> setupJpaRepository() {
//		return repository;
//	}
//
//	@Override
//	protected Class<ComposeAssetsActionDO> getDOClass() {
//		return ComposeAssetsActionDO.class;
//	}
//
//	@Override
//	protected Class<ComposeAssetsActionVO> getVOClass() {
//		return ComposeAssetsActionVO.class;
//	}
//
//	public ComposeAssetsActionVO findByCreateIdAndId(Long createId, Long id){
//		return convertVO(repository.findByCreateIdAndId(createId,id));
//	}
//
//
//	/**
//	 * 同步进行资金转入转出
//	 *
//	 * @param actionVO
//	 * @param assetsVO
//	 * @return
//	 */
//	public synchronized ComposeAssetsActionVO save(ComposeAssetsActionVO actionVO, ComposeAssetsVO assetsVO){
//		ComposeAssetsDO composeAssetsDO = PropertiesCopyUtil.copyProperties(assetsVO, ComposeAssetsDO.class);
//		ComposeAssetsActionVO result = convertVO(assetsActionHelper.save(convertDO(actionVO), composeAssetsDO));
//		return result;
//	}
//
////	public synchronized ComposeAssetsActionVO update(ComposeAssetsActionVO actionVO, ComposeAssetsVO assetsVO){
////		ComposeAssetsDO composeAssetsDO = PropertiesCopyUtil.copyProperties(assetsVO, ComposeAssetsDO.class);
////		ComposeAssetsActionVO result = convertVO(assetsActionHelper.action(convertDO(actionVO), composeAssetsDO));
////		return result;
////	}
//
//	public Page<ComposeAssetsActionVO> queryByCondition(ComposeAssetsActionVO queryVO, Integer pageNumber, Integer pageSize){
//		Specification specification = new Specification() {
//			@Override
//			public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
//				List<Predicate> predicates = new ArrayList<>();
//
//				if(null != queryVO.getCreateId()){
//					predicates.add(criteriaBuilder.equal(root.get("createId"), queryVO.getCreateId()));
//				}
//
//				if(null != queryVO.getCreateDate()){
//					predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createDate"), queryVO.getCreateDate()));
//				}
//
//				if(null != queryVO.getAssetsId()){
//					predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("assetsId"), queryVO.getAssetsId()));
//				}
//
//				return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
//			}
//		};
//		PageRequest pageRequest = PageUtil.buildPageRequest(pageNumber, pageSize);
//		return repository.findAll(specification,pageRequest);
//	}
//}
